using System.IO;
using UnityEditor;
using UnityEngine;

public class NetWorkDefine
{
    public const string k_Url = "https://common-res.996a.com/odin_test/OdinLiteAndroid/ServerData";

    public static int s_MaxDownloadingCount = 5;
    
    private static string m_persistentDataPath;

    public static string s_PersistentDataPath
    {
        get
        {
            if (string.IsNullOrEmpty(m_persistentDataPath))
            {
                m_persistentDataPath = Application.persistentDataPath;
            }
            return m_persistentDataPath;
        }
    }

    [MenuItem("OneKey/CopyOutput1Java2Unity")]
    public static void CopyOutput1Java2Unity()
    {
        string srcDir = $"{Directory.GetParent(Application.dataPath)}/Output1/unityLibrary/sgbackgrounddownload.androidlib/src";
        string destDir = $"{Application.dataPath}/TestHmNetWork/HmNetKit/Plugins/Android/sgbackgrounddownload.androidlib/src";
        CopyDirectory(srcDir, destDir);
    }
    
    static void CopyDirectory(string sourceDir, string targetDir)
    {
        // 获取源目录下所有文件和子目录
        foreach (string dirPath in Directory.GetDirectories(sourceDir, "*", SearchOption.AllDirectories))
        {
            Directory.CreateDirectory(dirPath.Replace(sourceDir, targetDir));
        }

        // 拷贝每个文件
        foreach (string filePath in Directory.GetFiles(sourceDir, "*.*", SearchOption.AllDirectories))
        {
            File.Copy(filePath, filePath.Replace(sourceDir, targetDir), true);
        }
    }
    
}